package com.seb.cc.gtou.helper;

import com.seb.cc.gtou.db.GTLieuDB;
import com.seb.cc.gtou.db.GTLieuPartDB;
import com.seb.cc.gtou.db.GTSejLieuDB;
import com.seb.cc.gtou.db.GTSejPartDB;
import com.seb.cc.gtou.db.GTSejourDB;
import com.seb.cc.gtou.db.GTParticipantDB;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class GTDatabaseHelper extends SQLiteOpenHelper {

	private static final String TAG = "TTOUProvider";
	private static final String DATABASE_NAME = "TTOU.db";
	private static final int DATABASE_VERSION = 1;

	public GTDatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	} // DatabaseHelper

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(GTSejourDB.SEJOUR_CREATE_TABLE);
		db.execSQL(GTParticipantDB.PARTICIPANT_CREATE_TABLE);
		db.execSQL(GTSejPartDB.SEJPART_CREATE_TABLE);
		db.execSQL(GTLieuDB.LIEU_CREATE_TABLE);
		db.execSQL(GTSejLieuDB.SEJLIEU_CREATE_TABLE);
		db.execSQL(GTLieuPartDB.LIEUPART_CREATE_TABLE);

	} // onCreate

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
				+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + GTSejourDB.SEJOUR_TABLE_NAME);
		db.execSQL("DROP TABLE IF EXISTS "
				+ GTParticipantDB.PARTICIPANT_TABLE_NAME);

		onCreate(db);
	} // onUpgrade

} // class SDDatabaseHelper